package com.eleventwelve.iris.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.opentides.bean.Auditable;
import org.opentides.bean.AuditableField;
import org.opentides.bean.BaseEntity;
import org.opentides.bean.Searchable;
import org.opentides.bean.Sortable;
import org.opentides.bean.SystemCodes;

/**
 * 
 * @author Ashley
 *
 */
@Entity
@Table(name="STAFF")
public class Staff extends BaseEntity implements Sortable, Auditable, Searchable{
	private static final long serialVersionUID = -4294282115144840829L;

	@Column(name="FIRST_NAME")
	private String firstName;
	
	@Column(name="LAST_NAME")
	private String lastName;
	
	@Column(name="MIDDLE_NAME")
	private String middleName;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="GENDER")
	private SystemCodes gender;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="STAFF_POSITION")
	private SystemCodes position;
	
	@Temporal(TemporalType.DATE)
	@Column(name="BIRTHDATE")
	private Date birthdate;

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getMiddleName() {
		return middleName;
	}

	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	public SystemCodes getGender() {
		return gender;
	}

	public void setGender(SystemCodes gender) {
		this.gender = gender;
	}

	public Date getBirthdate() {
		return birthdate;
	}

	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	public SystemCodes getPosition() {
		return position;
	}

	public void setPosition(SystemCodes position) {
		this.position = position;
	}
	
	public String getPrettyName(){
		return this.firstName+" "+this.lastName;
	}

	@Override
	public AuditableField getPrimaryField() {
		return new AuditableField("name");
	}
	
	@Override
	public List<String> getSearchProperties() {
		List<String> searchProperties = new ArrayList<String>();
		searchProperties.add("lastName");
		searchProperties.add("firstName");
		searchProperties.add("gender");
		searchProperties.add("position");
		return searchProperties;
	}
	
	
}
